use serde::Serialize;

use crate::utils::BitSet;


pub const PICK_CTRL: u8 = 0x04;
pub const COMPR_CTRL: u8 = 0x05;
pub const CARGO_CTRL: u8 = 0x06;
pub const SCAN: u8 = 0x07;
pub const SCAN_LED_CTRL: u8 = 0x08;
pub const ROW_COL_CTRL: u8 = 0x09;

#[derive(Debug, Serialize)]
pub struct StatusInfoDescript {
    version: String,
    cy_left: bool,
    cy_right: bool,
    cy_top: bool,
    cy_bottom: bool,
    pick_origin: bool,
    compr: bool,
    cargo_btn: bool,
    cargo_origin: bool,
    loc2: bool,
    pick_alm: bool,
    cargo_alm: bool,
}

impl StatusInfoDescript {

    pub fn new(version: String, sensor: u16) -> Self {
        StatusInfoDescript {
            version,
            cy_left: sensor.is_set(0),
            cy_right: sensor.is_set(1),
            cy_top: sensor.is_set(2),
            cy_bottom: sensor.is_set(3),
            pick_origin: sensor.is_set(4),
            compr: sensor.is_set(5),
            cargo_btn: sensor.is_set(6),
            cargo_origin: sensor.is_set(7),
            loc2: sensor.is_set(8),
            pick_alm: sensor.is_set(9),
            cargo_alm: sensor.is_set(10),
        }
    }
}
